/*
 * File Name：Repeat.java
 * Copyright：Copyright 2008-2015 CiWong.Inc. All Rights Reserved.
 * Description： Repeat.java
 * Modify By：bin
 * Modify Date：2015年1月20日
 * Modify Type：Add
 */
package com.ciwong.epaper.modules.epaper.bean;

import com.ciwong.mobilelib.bean.BaseBean;
import com.google.gson.Gson;

import java.util.Comparator;

/**
 * 答案
 * 
 * @author bin
 * @version ciwong v.1.0 2015年1月20日
 * @since ciwong v.1.0
 */
public class Answer extends BaseBean
{

    private static final long serialVersionUID = -4971291002290284772L;
    /**
     * 作业ID
     */
    private String workId = "0";


    /**
     *UUID格式的唯一会话ID,同一次考试使用一个
     */
    private  String sessionId;
    /**
     * 资源包ID
     */
    private String packageId = "0";

    /**
     * 作业内容ID(来源于学生作业记录接口)
     */
    private int contentId;
    /**
     * 目录ID
     */
    private String cId = "0";

    /**
     * 内容模块ID
     * {@link com.ciwong.epaper.modules.epaper.bean.ModuleInfo.ModuleInfoId}
     */
    private int moduleId;

    /**
     * 资源版本ID
     */
    private String versionId = "0";

    /**
     * 资源名称
     */
    private String resourceName;

    /**
     * 资源所有者的IP
     */
    private String parentVersionId = "0";

    /**
     * 作业用时(秒)
     */
    private int workLong;

    /**
     * 资源类型
     */
    private String resourceType;

    /**
     * 作业资源包版本,暂定为1.0
     */
    private String jsonVersion;

    /**
     * 参考答案JSON文件地址,相对路径,当前可固定为refAnswer.json
     */
    private String refAnswer;

    /**
     * 用户答案JSON文件地址.相对路径,当前可固定为userAnswer.json
     */
    private String userAnswer;

    /**
     * 作业答案
     */
    private String workAnswers;

    /**
     * 离线包创建时间
     */
    private long createTime;

    /**
     * 做作业ID
     */
    private String doWorkId;

    /**
     * 提交用户ID
     */
    private long userId;

    /**
     * 提交用户名
     */
    private String userName;

    /**
     * 
     * 作业实际得分
     */
    public float actualScore;

    /**
     * 作业提交内容URL
     */
    private String doWorkPackageUrl;

    /**
     * 作业本地路径
     */
    private String doWorkLocalPath;

    /**
     * 作业状态(1:已提交 2:退回 4:老师批改 8:无法识别答题卡)
     */
    private int workStatus;

    /**
     * 提交时间
     */
    private long submitDate;

    /**
     * 提交状态
     */
    public int submitStatus;

    /**
     * 提示失败提示
     */
    private String logInfo = "";

    /**
     * 进度
     */
    private int progress;

    /**
     * 作业参考总分值
     */
    public float workScore;

    /**
     * 答题卡编码
     */
    private long codeId;

    /**
     * 点评内容
     */
    private String comment;

    /**
     * 班级ID
     */
    private String classId;

    /**
     * 旧的需要被更新的同步测试doWorkId
     */
    private String oldDoWorkId;

    /**
     * 品牌ID
     */
    private int brandId;

    /**
     * 选中的资源
     */
    private String checkedResource;
    /**
     * 服务ID
     */
    private  int workType;
    /**
     * 未作答个数
     */
    public  String remainNum;

    /**
     * 错题的作业id
     */
    public  String errorWorkId;

    public boolean hasNoAnswers;

    public boolean isHasNoAnswers() {
        return hasNoAnswers;
    }

    public void setHasNoAnswers(boolean hasNoAnswers) {
        this.hasNoAnswers = hasNoAnswers;
    }




    public int getContentId() {
        return contentId;
    }

    public void setContentId(int contentId) {
        this.contentId = contentId;
    }

    public String getOldDoWorkId()
    {
        return oldDoWorkId;
    }

    public void setOldDoWorkId(String oldDoWorkId)
    {
        this.oldDoWorkId = oldDoWorkId;
    }

    public long getCodeId()
    {
        return codeId;
    }

    public void setCodeId(long codeId)
    {
        this.codeId = codeId;
    }

    public String getClassId()
    {
        return classId;
    }

    public void setClassId(String classId)
    {
        this.classId = classId;
    }

    public String getComment()
    {
        return comment;
    }

    public void setComment(String comment)
    {
        this.comment = comment;
    }

    public int getProgress()
    {
        return progress;
    }

    public void setProgress(int progress)
    {
        this.progress = progress;
    }

    public String getLogInfo()
    {
        return logInfo;
    }

    public void setLogInfo(String logInfo)
    {
        this.logInfo = logInfo;
    }

    public String getWorkId()
    {
        return workId;
    }

    public void setWorkId(String workId)
    {
        this.workId = workId;
    }

    public String getPackageId()
    {
        return packageId;
    }

    public void setPackageId(String packageId)
    {
        this.packageId = packageId;
    }

    public String getcId()
    {
        return cId;
    }

    public void setcId(String cId)
    {
        this.cId = cId;
    }

    public int getModuleId()
    {
        return moduleId;
    }

    public void setModuleId(int moduleId)
    {
        this.moduleId = moduleId;
    }

    public String getVersionId()
    {
        return versionId;
    }

    public void setVersionId(String versionId)
    {
        this.versionId = versionId;
    }

    public String getResourceName()
    {
        return resourceName;
    }

    public void setResourceName(String resourceName)
    {
        this.resourceName = resourceName;
    }

    public String getParentVersionId()
    {
        return parentVersionId;
    }

    public void setParentVersionId(String parentVersionId)
    {
        this.parentVersionId = parentVersionId;
    }

    public int getWorkLong()
    {
        return workLong;
    }

    public void setWorkLong(int workLong)
    {
        this.workLong = workLong;
    }

    public String getResourceType()
    {
        return resourceType;
    }

    public void setResourceType(String resourceType)
    {
        this.resourceType = resourceType;
    }

    public String getJsonVersion()
    {
        return jsonVersion;
    }

    public void setJsonVersion(String jsonVersion)
    {
        this.jsonVersion = jsonVersion;
    }

    public String getUserAnswer()
    {
        return userAnswer;
    }

    public void setUserAnswer(String userAnswer)
    {
        this.userAnswer = userAnswer;
    }

    public String getRefAnswer()
    {
        return refAnswer;
    }

    public void setRefAnswer(String refAnswer)
    {
        this.refAnswer = refAnswer;
    }

    public String getWorkAnswers()
    {
        return workAnswers;
    }

    public void setWorkAnswers(String workAnswers)
    {
        this.workAnswers = workAnswers;
    }

    public long getCreateTime()
    {

        return createTime;
    }

    public void setCreateTime(long createTime)
    {
        this.createTime = createTime;
    }

    public String getDoWorkId()
    {
        return doWorkId;
    }

    public void setDoWorkId(String doWorkId)
    {
        this.doWorkId = doWorkId;
    }

    public long getUserId()
    {
        return userId;
    }

    public void setUserId(long userId)
    {
        this.userId = userId;
    }

    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String userName)
    {
        this.userName = userName;
    }

    public float getActualScore()
    {
        return actualScore;
    }

    public void setActualScore(float actualScore)
    {
        this.actualScore = actualScore;
    }

    public String getDoWorkPackageUrl()
    {
        return doWorkPackageUrl;
    }

    public void setDoWorkPackageUrl(String doWorkPackageUrl)
    {
        this.doWorkPackageUrl = doWorkPackageUrl;
    }

    public String getDoWorkLocalPath()
    {
        return doWorkLocalPath;
    }

    public void setDoWorkLocalPath(String doWorkLocalPath)
    {
        this.doWorkLocalPath = doWorkLocalPath;
    }

    public int getWorkStatus()
    {
        return workStatus;
    }

    public void setWorkStatus(int workStatus)
    {
        this.workStatus = workStatus;
    }

    public long getSubmitDate()
    {
        return submitDate;
    }

    public void setSubmitDate(long submitDate)
    {
        this.submitDate = submitDate;
    }

    public int getSubmitStatus()
    {
        return submitStatus;
    }

    public void setSubmitStatus(int submitStatus)
    {
        this.submitStatus = submitStatus;
    }

    public float getWorkScore()
    {
        return workScore;
    }

    public void setWorkScore(float workScore)
    {
        this.workScore = workScore;
    }

    public int getBrandId()
    {
        return brandId;
    }

    public void setBrandId(int brandId)
    {
        this.brandId = brandId;
    }

    public String getCheckedResource()
    {
        return checkedResource;
    }


    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setCheckedResource(String checkedResource)
    {
        this.checkedResource = checkedResource;
    }

    public void setWorkType(int workType) {
        this.workType = workType;
    }

    public int getWorkType() {
        return workType;
    }

    public String getErrorWorkId() {
        return errorWorkId;
    }

    public void setErrorWorkId(String errorWorkId) {
        this.errorWorkId = errorWorkId;
    }

    public class WorkStatus
    {
        /**
         * 已提交
         */
        public static final int WORK_STATUS_SUMBITED = 1;

        /**
         * 退回
         */
        public static final int WORK_STATUS_BACK = 2;

        /**
         * 老师已批改
         */
        public static final int WORK_STATUS_CHECK = 4;

        /**
         * 无法识别答题卡
         */
        public static final int WORK_STATUS_UNKNOWN_CARD = 8;

    }

    public class SubmitStatus
    {
        /**
         * 作业提交失败（文件提交失败）
         */
        public static final int WORK_FILE_SUBMIT_FAILE = 1;

        /**
         * 作业提交失败（提交失败）
         */
        public static final int WORK_SUBMIT_FAILE = 2;

        /**
         * 作业提交失败（因未加班级而提交失败）
         */
        public static final int WORK_NO_ADD_CLASS_SUBMIT_FAILE = 3;

        /**
         * 作业提交失败（因未评分而提交失败）
         */
        public static final int WORK_NO_SCORE_FAILE = 4;

        /**
         * 作业正在提交
         */
        public static final int WORK_SUBMITING = 100;

        /**
         * 作业提交成功
         */
        public static final int WORK_SUBMIT_SUCCUED = 101;

        /**
         * 提交作业无班级错误
         */
        public static final int SUBMIT_WORK_NO_CLASS_ERROR = 5152;

        /**
         * 提交同步测试作业试卷编号不存在
         */
        public static final int SUBMIT_WORK_CARD_NOT_EXIST = 5158;

    }

    @Override
    public String toString()
    {
        return new Gson().toJson(this);
    }

    @Override
    public boolean equals(Object o)
    {
        if (o == null || !(o instanceof Answer))
        {
            return false;
        }
        return _id == ((Answer) o).get_id();
    }

    public static class AnswerComparator implements Comparator<Answer>
    {

        @Override
        public int compare(Answer lhs, Answer rhs)
        {
            if (lhs == null || rhs == null)
            {
                return 0;
            }
            return lhs.getSubmitStatus() - rhs.getSubmitStatus();
        }
    }
}
